import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Deck {

	private int size;
	private int maxSize;
	private Card deck[];
		
	public Deck(){
		
		maxSize = 52;
		size = 0;
		deck = new Card[maxSize];
	
		shuffle();
	}

  public Card dealCard() {
	  return deck[size--];	  
  }
  
  public void shuffle() {
	  // reset the deck
	  size = 0;
	  for (CardSuit suit : CardSuit.values())
          for (CardValue rank : CardValue.values())
              deck[size++] = new Card(suit, rank);
      // shuffle
      List tempList = Arrays.asList(deck);
      Collections.shuffle(tempList);
      deck = (Card[])tempList.toArray();
  }
  
  public int getSize()
  {
	  return size;
  }
  
  public String getDeck()
  {
	  String returnValue = "";
	  for(Card s : deck) returnValue += s.toString();
	  return "<deck>"+returnValue+"</deck>";
  }

}